package org.wzl.todolisthelper.controller;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wzl.todolisthelper.dto.AddPeriodicTaskDTO;
import org.wzl.todolisthelper.enumerate.PeriodicTaskRepetitionCycleEnum;
import org.wzl.todolisthelper.service.PeriodicTaskService;
import org.wzl.todolisthelper.utils.Resp;
import org.wzl.todolisthelper.vo.PeriodicTaskDetailVO;

@Slf4j
@RestController
@RequestMapping("/periodic")
public class PeriodicTaskController {

    @Resource
    private PeriodicTaskService periodicTaskService;

    @PostMapping("/addTask")
    public Resp<?> addTask(@RequestBody @Valid AddPeriodicTaskDTO addPeriodicTaskDTO) {
        periodicTaskService.addTask(addPeriodicTaskDTO);
        return Resp.ok();
    }

    @GetMapping("/getAllCard")
    public Resp<?> getAllCard() {
        return Resp.ok(periodicTaskService.getAllCard());
    }

    @GetMapping("/getAllRepetitionCycle")
    public Resp<?> getAllRepetitionCycle() {
        return Resp.ok(PeriodicTaskRepetitionCycleEnum.getAll());
    }

    @GetMapping("/getDetailById")
    public Resp<PeriodicTaskDetailVO> getDetailById(String id) {
        return Resp.ok(periodicTaskService.getDetailById(id));
    }

}
